package com.swim.phonenumprivacy.config;

import com.aliyun.teaopenapi.models.Config;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliyunAxbConfig { 
    @Value("${aly.DOMAIN}")
    private String DOMAIN;
    @Value("${aly.ACCESS_KEY_ID}")
    private String ACCESS_KEY_ID;
    @Value("${aly.ACCESS_KEY_SECRET}")
    private String ACCESS_KEY_SECRET;

    @Bean
    @SneakyThrows(value = Exception.class)
    com.aliyun.dyplsapi20170525.Client createClient() throws Exception {
        Config config = new Config()
                //AccessKey ID
                .setAccessKeyId(ACCESS_KEY_ID)
                // AccessKey Secret
                .setAccessKeySecret(ACCESS_KEY_SECRET);
        // 访问的域名
        config.endpoint = DOMAIN;
        return new com.aliyun.dyplsapi20170525.Client(config);
    }
}
